﻿using System;
using System.Collections.Generic;
using System.Text;

namespace NetFtp.Core.Login
{
    /// <summary>
    /// Un compte FTP.
    /// </summary>
    public class FtpAccount
    {
        private int id;
        private string hostname;
        private string username;
        private string password;
        private string folder;
        private int port;

        #region Constructeurs
        /// <summary>
        /// Constructeur par défaut
        /// </summary>
        public FtpAccount() :
            this("", "", "")
        {
        }
        /// <summary>
        /// Constructeur la session avec identification
        /// </summary>
        /// <param name="hostname"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        public FtpAccount(string hostname, string username, string password)
        {
            this.hostname = hostname;
            this.username = username;
            this.password = password;
            this.port = 21;
            this.folder = "/";
        }
        /// <summary>
        /// Constructeur la session avec identification
        /// </summary>
        /// <param name="hostname"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="port"></param>
        /// <param name="folder"></param>
        public FtpAccount(string hostname, string username, string password, int port, string folder)
        {
            this.hostname = hostname;
            this.username = username;
            this.password = password;
            this.port = port;
            if (folder == "")
                this.folder = "/";
            else
                this.folder = folder;
        }
        /// <summary>
        /// Constructeur la session avec identification
        /// </summary>
        /// <param name="hostname"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="port"></param>
        /// <param name="folder"></param>
        public FtpAccount(int id, string hostname, string username, string password, int port, string folder)
        {
            this.id = id;
            this.hostname = hostname;
            this.username = username;
            this.password = password;
            this.port = port;
            if (folder == "")
                this.folder = "/";
            else
                this.folder = folder;
        }
        #endregion

        #region Proprietes
        /// <summary>
        /// Obtient l'id
        /// </summary>
        public int Id
        {
            get
            {
                return this.id;
            }
        }
        /// <summary>
        /// Obtient/modifie le hostname
        /// </summary>
        public string Hostname
        {
            get
            {
                return this.hostname;
            }

            set
            {
                if (string.IsNullOrEmpty(value))
                    throw new ArgumentNullException("hostname cannot be null");

                if (this.hostname != value)
                {
                    this.hostname = value;
                }
            }
        }
        /// <summary>
        /// Obtient/modifie le username
        /// </summary>
        public string Username
        {
            get
            {
                return this.username;
            }

            set
            {
                if (string.IsNullOrEmpty(value))
                    throw new ArgumentNullException("username cannot be null");

                if (this.username != value)
                {
                    this.username = value;
                }
            }
        }
        /// <summary>
        /// défini/modifie le password
        /// </summary>
        public string Password
        {
            get
            {
                return this.password;
            }
            set
            {
                if (string.IsNullOrEmpty(value))
                    throw new ArgumentNullException("password cannot be null");

                if (this.password != value)
                {
                    this.password = value;
                }
            }
        }
        /// <summary>
        /// défini/modifie le port
        /// </summary>
        public int Port
        {
            get
            {
                return this.port;
            }
            set
            {
                this.port = value;
            }
        }
        /// <summary>
        /// défini/modifie le repertoire
        /// </summary>
        public string Folder
        {
            get
            {
                return this.folder;
            }
            set
            {
                this.folder = value;
            }
        }
        #endregion
    }
}
